<?php

namespace App\Http\Controllers\Admin;

use App\Models\Banner\LiveBanner;
use App\Models\User\Vip;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;
use App\Http\Controllers\PCHController;

class VipCardController extends Controller
{
    public function getVipCard(Request $request)
    {
        $data = Vip::query()->get();
        return self::response($data,200);
    }

    /**
     * 新增/修改 配置
     * @param Request $request
     * @return mixed
     */
    public function modifyVip(Request $request)
    {
        $input = $request->all();

        if (empty($input['need_score'])){
            return self::response(null,'-1','need_score is null');
        }
        $need_score = (int)$input['need_score'];
        if ($need_score<0){
            return self::response(null,'-1','积分必须是正整数');
        }
        if (empty($input['id'])){
            return self::response(null,'-1','id is null');
        }
        $flag = Vip::query()->where('id',$input['id'])->update(['need_score'=>(int)$need_score]);
        if ($flag){
            return self::response(null,200,'修改成功');
        }else{
            return self::response(null,-1,'修改失败');
        }
    }
}
